package com.example.reggie;

public class Foodie {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()-> {
            //5s后终断线程A
            try {
                Thread.sleep(1000 * 5);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("111111111111");
        });

        t.setName("A");
        t.start();
        Thread.sleep(1000);
        //此行代码是终断线程A的睡眠(此终断机制依靠java异常处理机制)
        t.interrupt();
    }

}
